using System;
using System.IO;
using System.Xml.Serialization;
namespace CommandLib.Base
{
	public class SerializableHelper
	{
		public static void SerializeSetting<T>(T model, string path)
		{
			XmlSerializer xmlSerializer = new XmlSerializer(typeof(T));
			using (StreamWriter streamWriter = new StreamWriter(path))
			{
				xmlSerializer.Serialize(streamWriter, model);
				streamWriter.Close();
			}
		}
		public static T DeserializeSetting<T>(string path)
		{
			XmlSerializer xmlSerializer = new XmlSerializer(typeof(T));
			T result;
			using (FileStream fileStream = new FileStream(path, FileMode.Open))
			{
				T t = (T)xmlSerializer.Deserialize(fileStream);
				fileStream.Close();
				result = t;
			}
			return result;
		}
	}
}
